import { ref } from 'vue';

const useBookTransfer = () => {

    const bookTransferVisible = ref(false);
    const transferAndRemittanceVisible = ref(false);
    const dataRow = ref(null);
    const collectionOfPaymentsType = ref(1); // 1 转账汇款 2 外部收款

    /** 打开 内部转账 弹窗 */
    const handlOpenBookTransfer = async (row: any) => {
        dataRow.value = row;
        bookTransferVisible.value = true;
    };

    /** 关闭 内部转账 弹窗 */
    const handleCloseBookTransfer = () => {
        bookTransferVisible.value = false;
    };

    /** 打开 转账汇款 弹窗 */
    const handlOpenTransferAndRemittance = async (row: any) => {
        dataRow.value = row;
        collectionOfPaymentsType.value = 1;
        transferAndRemittanceVisible.value = true;
    };

    /** 关闭 转账汇款 弹窗 */
    const handleCloseTransferAndRemittance = () => {
        transferAndRemittanceVisible.value = false;
    };

    /** 打开 外部收款 弹窗 */
    const handlOpenCollectionOfPayments = async (row: any) => {
        dataRow.value = row;
        collectionOfPaymentsType.value = 2;
        transferAndRemittanceVisible.value = true;
    };

    return {
        bookTransferVisible,
        transferAndRemittanceVisible,
        collectionOfPaymentsType,
        dataRow,
        handlOpenBookTransfer,
        handleCloseBookTransfer,
        handlOpenTransferAndRemittance,
        handleCloseTransferAndRemittance,
        handlOpenCollectionOfPayments
    }
};

export default useBookTransfer;
